Code:
main:
pushq %rbp
movq %rsp, %rbp
subq $8, %rsp
movq $18446744073709551614, %r13 #our number
addq %r13, %r13
jnc nocarry // This branch will never be taken
movq $1, %rbx
movq %rbx, (%rsp)
addq $8, %rsp // After this instruction, %rsp == %rbp
nocarry:
movq %r13, (%rsp) // Equivalent to "movq %r13, (%rbp)" -- you just trashed (%rbp), but since we are in the "main" function, I'm not sure of the consequences
movl $0, %eax
leave
Don't forget that the PUSH instruction on the x86-64 ISA is "Decrements the stack pointer and then stores the source operand on the top of the stack". So when you write "subq $8, %rsp", you are creating 8 bytes of stack space, which is not enough to hold your 16 bytes value. Personnaly, I would do it this way
Code:
main:
pushq %rbp
movq %rsp, %rbp
subq $16, %rsp
movq $18446744073709551614, %r13 #our number
addq %r13, %r13
jnc nocarry
movq $1, %rbx
movq %rbx, -16(%rbp)
nocarry:
movq %r13, -8(%rbp)
# Here you want to print -16(%rbp):-8(%rbp)
movl $0, %eax
leave
So you don't have to care about the value of %rsp.